// hook函数
// 1. 对组件功能的抽取
// 2. 命名是以useXXX

import { getMedicalOrderDetail } from "@/apis/order"
import type { MedicalOrderDetail } from "@/types/room"
import { ref } from "vue"

export const useMedic = (orderId: string) => {
  const orderDetail = ref<MedicalOrderDetail>({} as MedicalOrderDetail)
  const getOrderDetail = async () => {
    if (orderId === '') {
      uni.showToast({ title: '订单出现问题', icon: 'none' })
      uni.switchTab({
        url: '/pages/my/index',
      })
    }
    const res = await getMedicalOrderDetail(orderId)
    orderDetail.value = res
    console.log(orderDetail.value)
  }
  getOrderDetail()

  return { orderDetail }
}